#ifndef AVATARDB_H
#define AVATARDB_H

#include "0-data/avatar.h"

#include <QObject>
#include <QList>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlError>

class AvatarDb : QObject
{
    Q_OBJECT
public:
    AvatarDb(QObject *parent = nullptr);
    ~AvatarDb();

public:
    bool GetAllAvatars(QList<Avatar> &result_list);
    bool GetAvatarByName(const QString &name, QList<Avatar> &result_list);
    bool SaveAvatar(const Avatar &avatar);
    bool SaveAvatars(const QList<Avatar> &avatars);
    bool DeleteAvatar(const Avatar &avatar);
    bool DeleteAvatars(const QList<Avatar> &avatars);

private:
    void CheckDbStructure();

private:
    QSqlDatabase db_;

    bool is_valid_;
};

#endif // AVATARDB_H
